import React from 'react';
import { Form, Row, DatePicker, Button, Select, Input, Col } from 'antd';
const FormItem = Form.Item;
const { Option } = Select;
const { RangePicker } = DatePicker

const SearchForm = ({ form: { getFieldDecorator, getFieldsValue }, onSearch, onClick, advanced, searchItem, resetForm }) => {
  const onHandleAdvanced = () => {
    if (onClick) {
      onClick();
    }
  };
  const formItemLayout = {
    // 抽屉里面Form。二列的布局比例
    labelCol: {
      span: 6
    },
    wrapperCol: {
      span: 16
    }
  };
  return (
    <Form className="search-form">
      <Row gutter={24}>
        <Col span={5}>
          <FormItem label="检验项目编码"{...formItemLayout}>
            {getFieldDecorator('checkItemCode', {
              initialValue: searchItem.checkItemCode || ''
            })(
              <Input placeholder='请输入检验项目编码' allowClear onPressEnter={() => onSearch(getFieldsValue())} />
            )}
          </FormItem>
        </Col>
        <Col span={5}>
          <FormItem label="检验项目名称"{...formItemLayout}>
            {getFieldDecorator('checkItemName', {
              initialValue: searchItem.checkItemName || ''
            })(
              <Input placeholder='请输入检验项目名称' allowClear onPressEnter={() => onSearch(getFieldsValue())} />
            )}
          </FormItem>
        </Col>
        <Col span={5}>
          <FormItem label="所属分类"{...formItemLayout}>
            {getFieldDecorator('checkTypeSecond', {
              initialValue: searchItem.checkTypeSecond || ''
            })(
              <Input placeholder='请输入所属分类' allowClear onPressEnter={() => onSearch(getFieldsValue())} />
            )}
          </FormItem>
        </Col>
        <Col span={5}>
          <FormItem label="状态"{...formItemLayout}>
            {getFieldDecorator('checkResult', {
              initialValue: searchItem.checkResult || ''
            })(
              <Input placeholder='请输入状态' allowClear onPressEnter={() => onSearch(getFieldsValue())} />
            )}
          </FormItem>
        </Col>
        <Col span={4} style={{ display: 'flex' }} className="serarch-btns">
          <FormItem>
            <Button icon="search" type="primary" onClick={() => onSearch(getFieldsValue())}>
              {'查询'}
            </Button>
          </FormItem>
          {/* <FormItem>
            <Button type="primary" icon={advanced ? 'up' : 'down'} onClick={() => onHandleAdvanced()}>
              {'展开'}
            </Button>
          </FormItem> */}
          <FormItem>

            <Button type="default" icon={'redo'} onClick={() => resetForm()}>
              {'重置'}
            </Button>
          </FormItem>
        </Col>
      </Row>
      {/* <Row gutter={24}>
        {
          advanced ? <Col span={5}>
            <FormItem label="交机日期"{...formItemLayout}>
              {getFieldDecorator('firstDeliveryDate')(
                <RangePicker allowClear />
              )}
            </FormItem>
          </Col> : ''
        }
        {
          advanced ? <Col span={5}>
            <FormItem label="出机日期"{...formItemLayout}>
              {getFieldDecorator('assembleStartDate')(
                <RangePicker allowClear />
              )}
            </FormItem>
          </Col> : ''
        }
        {
          advanced ? <Col span={5}>
            <FormItem label="申请人"{...formItemLayout}>
              {getFieldDecorator('applyUserName', {
                initialValue: searchItem.applyUserName || ''
              })(
                <Input placeholder='请输入申请人' allowClear onPressEnter={() => onSearch(getFieldsValue())} />
              )}
            </FormItem>
          </Col> : ''
        }
      </Row> */}
    </Form>
  );
};

export default Form.create()(SearchForm);
